﻿
using System.Collections.Generic;
using System.Drawing;
using System.IO;

namespace GDFlacTool.Common
{
    public class PrintingObject
    {
        private string _album = string.Empty;
        private string _artist = string.Empty;
        private string _albumartist = string.Empty;
        private string _year = string.Empty;
        private string _genre = string.Empty;
        private string _comment = string.Empty;
        private string _catalog = string.Empty;
        private Image _art; 

        public PrintingObject(Track track)
        {
            _album = track.Album;
            _artist = track.Artist;
            _albumartist = track.Albumartist;

            if(track.HasFileCoverArt)
            {
                Stream s = new MemoryStream(track.ArtByteArray);
                _art = Image.FromStream(s);
            }
        }
        
        public string Album
        {
            get
            {
                if(!string.IsNullOrEmpty(_album))
                {
                    return _album;
                }
                
                return "# Missing!";
            }
            set
            {
                _album = value;
            }
        }

        public string Artist
        {
            get
            {
                if (!string.IsNullOrEmpty(_album))
                {
                    return _artist;
                }
                
                return "# Missing!";
            }
            set
            {
                _artist = value;
            }
        }

        public Image Art
        {
            get { return _art; }
            set { _art = value; }
        }

        public string AlbumArtist
        {
            get
            {
                if (!string.IsNullOrEmpty(_albumartist))
                {
                    return _albumartist;
                }

                return "# Missing!";
            }
            set { _albumartist = value; }
        }

        private void Init()
        {
            
        }
    }

    public class PrintingObjectCollection : List<PrintingObject>
    {
        public PrintingObjectCollection(IEnumerable<Track> tracks)
        {
            foreach (var track in tracks)
            {
                var obj = new PrintingObject(track);

                Add(obj);
            }
        }

        public List<PrintingObject> GetPrintingObjects()
        {
            return this;
        }
    }

    //public class Title
    //{
    //    private string _title = string.Empty;
    //    private string _trackNumber = string.Empty;
    //    private string _discNumber = string.Empty;


    //}

    //public class TitleCollection : List<Title>
    //{
        
    //}
}
